<template>
  <div class="">
    <div v-if="isShow">
      <el-form :inline="true" :model="query" class="query-form" size="small">
        <el-form-item >
          <span >入驻状态：</span>
          <el-select v-model="query.certificationstatus" placeholder="请选择入驻状态" @change="onSubmit" clearable>
              <!-- <el-option  label="全部"  value=''>  </el-option> -->
              <el-option  label="审核中"  value='0'> </el-option>
              <el-option label="已通过" value='1'> </el-option>
              <el-option label="已驳回" value='2'> </el-option>
              <el-option label="待提交" value='3'> </el-option>
          </el-select>
        </el-form-item>

        <el-form-item class="query-form-item">
          <el-input
            v-model="query.userPhone"
            placeholder="请输入手机号"
            prefix-icon="el-icon-search"
            @keyup.enter.native="onSubmit"
            clearable
          ></el-input>
        </el-form-item>

        <el-form-item class="query-form-item">
          <el-input
            v-model="query.enterpriseName"
            placeholder="请输入企业名称"
            prefix-icon="el-icon-search"
            @keyup.enter.native="onSubmit"
            clearable
          ></el-input>
        </el-form-item>

        <el-form-item class="query-form-item">
          <el-input
            v-model="query.RegistrationNumber"
            placeholder="请输入营业执照编号"
            prefix-icon="el-icon-search"
            @keyup.enter.native="onSubmit"
            clearable
          ></el-input>
        </el-form-item>

        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-refresh"
            @click="onRest"
          ></el-button>
          <el-button type="primary" icon="el-icon-search" @click="onSubmit"
            >查询</el-button
          >
        </el-form-item>
      </el-form>

      <el-table
        v-loading="loading"
        :data="list"
        :header-cell-style="{ background: '#F4F4F5', color: '#606266' }"
        border
      >
        <el-table-column
          label="账号"
          prop="userMobile"
          align="center"
        ></el-table-column>
         <el-table-column
          label="企业名称"
          prop="enterpriseName"
          align="center"
        ></el-table-column>
        <el-table-column
          label="营业执照编号"
          prop="registrationNumber"
          align="center"
        ></el-table-column>
        <el-table-column label="提交时间" prop="submittime" align="center">
          <template slot-scope="scope">
            {{
              scope.row.submittime | formatDateStr('yyyy-MM-dd hh:mm:ss')
            }}
          </template>
        </el-table-column>
        <el-table-column
          label="入驻信息审核状态"
          prop="accountStatus"
          align="center"
        >
          <template slot-scope="scope">
            <span
              style="color: #4acf1e"
              v-if="scope.row.certificationstatus == 1"
              >已通过</span
            >
            <span
              style="color: #dc0101"
              v-else-if="scope.row.certificationstatus == 2"
              >已驳回</span
            >
            <span
              style="color: #ffa659"
              v-else-if="scope.row.certificationstatus == 0"
              >审核中</span
            >
            <span style="color: #ffa659" v-else>待提交</span>
          </template>
        </el-table-column>
        <el-table-column label="商家注册资料" align="center">
          <template slot-scope="scope">
            <el-button
              type="primary"
              size="mini"
              @click.native="showEdit(1, scope.$index, scope.row)"
              >查看</el-button
            >
          </template>
        </el-table-column>
<!--        <el-table-column label="商家商品审核" align="center">-->
<!--          <template slot-scope="scope">-->
<!--            <el-button-->
<!--              type="primary"-->
<!--              size="mini"-->
<!--              @click.native="showEdit(2, scope.$index, scope.row)"-->
<!--              >查看</el-button-->
<!--            >-->
<!--          </template>-->
<!--        </el-table-column>-->
        <el-table-column label="商家入驻审核" align="center">
          <template slot-scope="scope">
            <el-button
              type="primary"
              size="mini"
              @click.native="showEdit(3, scope.$index, scope.row)"
              >查看</el-button
            >
          </template>
        </el-table-column>
      </el-table>

      <!--分页模块start-->
      <el-pagination
        class="pagination-container"
        background
        :page-size="query.pageSize"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        layout="total,sizes,prev, pager, next, jumper"
        :current-page="query.currentPage"
        :page-sizes="[10, 20, 30, 50]"
        :total="totalNumber"
      ></el-pagination>
      <!--分页模块end-->
      <!--商城营业执照审核-->
      <el-dialog
        v-if="list.length > 0"
        title="商城信息"
        :visible.sync="showEditPage1"
        width="40%"
        :before-close="closeDialog"
        :close-on-click-modal="false"
      >
        <span>
          <ul class="topList">
            <li>用户名：{{ list[index].userNick || '' }}</li>
            <li>公司名称：{{ list[index].enterpriseName }}</li>
            <li>营业执照编码：{{ list[index].registrationNumber }}</li>
            <li>联系人：{{ list[index].realname }}</li>
            <li>联系方式：{{ list[index].userMobile }}</li>
            <li>
              申请时间：{{
                list[index].userRegistTime | formatDateStr('yyyy/MM/dd')
              }}
            </li>
            <li style="color: red">
              总进货额：{{ list[index].accountMoney || 0 }}
            </li>
            <li style="color: red">
              代理商品进货额：{{ list[index].commodityPerformance || 0 }}
            </li>
          </ul>

          <div class="qualificationCertificate">
            <el-row :gutter="20">
              <el-col :span="6">
                <el-popover placement="right" trigger="click">
                  <img
                    :src="list[index].businessLicense"
                    style="
                      max-width: 1000px;
                      max-height: 90vh;
                      border-radius: 3px;
                    "
                  />
                  <div slot="reference" class="imgBox">
                    <img :src="list[index].businessLicense" />
                    <p @click.stop>公司营业执照</p>
                  </div>
                </el-popover>
              </el-col>
              <el-col :span="6">
                <el-popover placement="right" trigger="click">
                  <img
                    :src="list[index].authorizationCertificate"
                    style="
                      max-width: 1000px;
                      max-height: 90vh;
                      border-radius: 3px;
                    "
                  />
                  <div slot="reference" class="imgBox">
                    <img :src="list[index].authorizationCertificate" />
                    <p @click.stop>授权证明</p>
                  </div>
                </el-popover>
              </el-col>
              <el-col :span="6">
                <el-popover placement="right" trigger="click">
                  <img
                    :src="list[index].identityCardPositive"
                    style="
                      max-width: 1000px;
                      max-height: 90vh;
                      border-radius: 3px;
                    "
                  />
                  <div slot="reference" class="imgBox">
                    <img :src="list[index].identityCardPositive" />
                    <p @click.stop>身份证正面</p>
                  </div>
                </el-popover>
              </el-col>
              <el-col :span="6">
                <el-popover placement="right" trigger="click">
                  <img
                    :src="list[index].identityCardBack"
                    style="
                      max-width: 1000px;
                      max-height: 90vh;
                      border-radius: 3px;
                    "
                  />
                  <div slot="reference" class="imgBox">
                    <img :src="list[index].identityCardBack" />
                    <p @click.stop>身份证反面</p>
                  </div>
                </el-popover>
              </el-col>
            </el-row>
          </div>
        </span>
        <span slot="footer" class="dialog-footer">
          <el-button @click="showEditPage1 = false">取消</el-button>
        </span>
      </el-dialog>
      <!--商城经营类目审核-->
      <el-dialog
        v-if="list.length > 0"
        title="商家商品审核"
        :visible.sync="showEditPage2"
        width="1000px"
        :before-close="closeDialog"
        :close-on-click-modal="false"
      >
        <span>
          <ul class="topList">
            <li>用户名：{{ list[index].userNick || '' }}</li>
            <li>公司名称：{{ list[index].enterpriseName }}</li>
            <li>营业执照编码：{{ list[index].registrationNumber }}</li>
            <li>联系人：{{ list[index].realname }}</li>
            <li>联系方式：{{ list[index].userMobile }}</li>
            <li>
              申请时间：{{
                list[index].userRegistTime | formatDateStr('yyyy/MM/dd')
              }}
            </li>
            <li style="color: red">
              总进货额：{{ list[index].accountMoney || 0 }}
            </li>
            <li style="color: red">
              代理商品进货额：{{ list[index].commodityPerformance || 0 }}
            </li>
            <li>
              <a
                class="getList"
                @click="goCommodityManagement(list[index])"
                style="color: #1e6abc"
                >去审核商品 >></a
              >
            </li>
          </ul>
        </span>
        <span slot="footer" class="dialog-footer">
          <el-button @click="showEditPage2 = false">取消</el-button>
        </span>
      </el-dialog>
      <!-- 商家入驻审核 -->
      <el-dialog
        class="settledInfo"
        v-if="list.length > 0"
        :title="
          '商家入驻审核 ' +
          (formSettled.certificationstatus == 1
            ? ' (已通过) '
            : formSettled.certificationstatus == 2
            ? ' (已驳回) '
            : ' (待审核) ')
        "
        :visible.sync="showEditPage3"
        width="50%"
        :before-close="closeDialog"
        :close-on-click-modal="false"
      >
        <el-form :model="formSettled" label-width="200px" top="50px">
          <h3 class="thrTitle">公司及联系人信息</h3>
          <el-form-item label="公司名称：" prop="companyname">
            <span>{{ formSettled.companyname }}</span>
          </el-form-item>
          <el-form-item label="公司所在地：" prop="county">
            <span>{{ formSettled.province }} / </span>
            <span>{{ formSettled.city }} / </span>
            <span>{{ formSettled.county }}</span>
          </el-form-item>
          <el-form-item label="公司详细地址：" prop="address">
            <span>{{ formSettled.address }}</span>
          </el-form-item>
          <el-form-item label="电子邮箱：" prop="email">
            <span>{{ formSettled.email }}</span>
          </el-form-item>
          <el-form-item label="公司电话：" prop="companyphone">
            <span>{{ formSettled.companyphone }}</span>
          </el-form-item>
          <el-form-item label="联系人姓名：" prop="contactname">
            <span>{{ formSettled.contactname }}</span>
          </el-form-item>
          <el-form-item label="联系人电话：" prop="contactphone">
            <span>{{ formSettled.contactphone }}</span>
          </el-form-item>
          <el-form-item label="员工总数（人）：" prop="totalstaff">
            <span>{{ formSettled.totalstaff }}</span>
          </el-form-item>
          <el-form-item
            label="注册资金（万元）："
            type="number"
            prop="registeredcapital"
          >
            <span>{{ formSettled.registeredcapital }}</span>
          </el-form-item>
          <h3 class="thrTitle">印业执照信息（副本）</h3>
          <el-form-item label="营业执照号：" prop="businesslicensenumber">
            <span>{{ formSettled.businesslicensenumber }}</span>
          </el-form-item>
          <el-form-item label="营业执照有效期：" prop="businesslicenseindate">
            <span>{{ formSettled.businesslicenseindate }}</span>
          </el-form-item>
          <el-form-item label="营业执照电子版：" prop="businesslicenseurl">
            <el-popover placement="right" trigger="click">
              <img
                :src="formSettled.businesslicenseurl"
                style="max-width: 1000px; max-height: 90vh; border-radius: 3px"
              />
              <div slot="reference" class="imgBox">
                <img :src="formSettled.businesslicenseurl" />
                <p @click.stop>营业执照电子版</p>
              </div>
            </el-popover>
          </el-form-item>
            <el-form-item label="授权代表证明：" prop="authorizationcertificate">
                <el-popover placement="right" trigger="click">
                    <img
                        :src="formSettled.authorizationcertificate"
                        style="max-width: 1000px; max-height: 90vh; border-radius: 3px"
                    />
                    <div slot="reference" class="imgBox">
                        <img :src="formSettled.authorizationcertificate" />
                        <p @click.stop>营业执照电子版</p>
                    </div>
                </el-popover>
            </el-form-item>
          <el-form-item label="一般纳税人证明：" prop="taxpayercertificateurl">
            <el-popover placement="right" trigger="click">
              <img
                :src="formSettled.taxpayercertificateurl"
                style="max-width: 1000px; max-height: 90vh; border-radius: 3px"
              />
              <div slot="reference" class="imgBox">
                <img :src="formSettled.taxpayercertificateurl" />
                <p @click.stop>一般纳税人证明</p>
              </div>
            </el-popover>
          </el-form-item>
          <h3 class="thrTitle">开户银行信息</h3>
          <el-form-item label="银行开户名：" prop="accountname">
            <span>{{ formSettled.accountname }}</span>
          </el-form-item>
          <el-form-item label="公司银行账号：" prop="accountnumber">
            <span>{{ formSettled.accountnumber }}</span>
          </el-form-item>
          <el-form-item label="开户银行支行名称：" prop="subbranchname">
            <span>{{ formSettled.subbranchname }}</span>
          </el-form-item>
          <!-- <el-form-item label="支行联行号：" prop="affiliatedbanknumber">
                        <span>{{formSettled.affiliatedbanknumber}}</span>
                    </el-form-item> -->
          <el-form-item label="开户银行所在地：" prop="bankaddress">
            <span>{{ formSettled.bankaddress }}</span>
          </el-form-item>
          <!-- <el-form-item label="开户银行许可证电子版：" prop="banklicenceurl">
                        <el-popover placement="right"
                                    trigger="click">
                            <img :src="formSettled.banklicenceurl"
                                 style="max-width:1000px;max-height: 90vh;border-radius:3px;">
                            <div slot="reference"
                                 class="imgBox">
                                <img :src="formSettled.banklicenceurl">
                                <p @click.stop>开户银行许可证电子版</p>
                            </div>
                        </el-popover>
                    </el-form-item> -->
          <h3 class="thrTitle">支付宝</h3>
          <el-form-item label="支付宝姓名：" prop="alipayname">
            <span>{{ formSettled.alipayname }}</span>
          </el-form-item>
          <el-form-item label="支付宝账号：" prop="alipaynumber">
            <span>{{ formSettled.alipaynumber }}</span>
          </el-form-item>
          <h3 class="thrTitle">微信</h3>
          <el-form-item label="微信姓名：" prop="wechatname">
            <span>{{ formSettled.wechatname }}</span>
          </el-form-item>
          <el-form-item label="微信账号：" prop="wechatnumber">
            <span>{{ formSettled.wechatnumber }}</span>
          </el-form-item>
          <h3 class="thrTitle">店铺经营信息</h3>
          <el-form-item label="店铺名称：" prop="storename">
            <span>{{ formSettled.storename }}</span>
            <!-- <el-input v-model="formSettled.storename"></el-input> -->
          </el-form-item>
          <el-form-item label="商品类目：" prop="categoryid">
            <span>{{ formSettled.topcategoryname }} / </span>
            <span>{{ formSettled.secondarycategoryname }} / </span>
            <span>{{ formSettled.thirdcategoryname }}</span>
          </el-form-item>
          <el-form-item label="经营方式：" prop="templateType">
            <span>{{ formSettled.templatetype | getTemplateTyep }}</span>
          </el-form-item>
          <div v-if="categoryTemplate != [] && categoryTemplate != null">
            <h3 class="thrTitle">{{ categoryTemplate.name }}</h3>
            <el-form-item
              :prop="item.fieldname"
              :label="item.fieldname + '：'"
              v-for="item in categoryTemplate.templateItemFormList"
              :key="item.id"
            >
              <span v-if="item.fieldtype != '图片'">{{ item.fieldvalue }}</span>
              <el-popover placement="right" trigger="click" v-else>
                <img
                  :src="item.fieldvalue"
                  style="
                    max-width: 1000px;
                    max-height: 90vh;
                    border-radius: 3px;
                  "
                />
                <div slot="reference" class="imgBox">
                  <img :src="item.fieldvalue" />
                  <p @click.stop>{{ item.fieldname }}</p>
                </div>
              </el-popover>
            </el-form-item>
          </div>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button
            :disabled="formSettled.certificationstatus != 0"
            type="danger"
            @click="rejectionApplication(3, formSettled)"
            >驳 回</el-button
          >
          <el-button
            :disabled="formSettled.certificationstatus != 0"
            type="primary"
            @click="passApplication(3, formSettled)"
            >审核通过</el-button
          >
        </span>
      </el-dialog>
      <el-dialog title="请填写驳回原因" :visible.sync="dialogFormVisible">
        <el-form>
          <el-form-item label="驳回原因：">
            <el-input type="textarea" v-model="reasons"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible = false">取 消</el-button>
          <el-button type="primary" @click="reject">确 定</el-button>
        </div>
      </el-dialog>
      <!-- 商家入驻驳回 -->
      <el-dialog
        title="请填写驳回原因"
        :visible.sync="dialogFormVisible1"
        width="50%"
        top="5vh"
        v-dialogDrag
      >
        <el-form>
          <el-form-item label="驳回原因：">
            <el-input
              type="textarea"
              style="width: 80%"
              maxlength="300"
              show-word-limit
              :autosize="{ minRows: 4, maxRows: 10 }"
              v-model="reasonsSettlement"
            ></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible1 = false">取 消</el-button>
          <el-button type="primary" @click="rejectSettlement">确 定</el-button>
        </div>
      </el-dialog>
    </div>
    <div v-if="!isShow">
      <CommodityManagement
        @goBack="goBack"
        :getListQuery="getListQuery"
      ></CommodityManagement>
    </div>
  </div>
</template>

<script>
import {
  getCheckUser,
  getCertificationInfoList,
  merchantsCertificationAudit,
  updateCheckEntityStatus,
  getDetailInfo, // 商家入驻审核信息详情
  audit, // 商家入驻审核
  getDetailById, // 根据类名id获取类目名称
} from '../../api/classification/classification.js'
import CommodityManagement from './commodityManagement'
export default {
  components: { CommodityManagement },
  data() {
    return {
      query: {
        currentPage: 1,
        pageSize: 10,
        userPhone:"",
        UserNick :"",
        certificationstatus:'',
        RegistrationNumber:'',
        enterpriseName:""
      },
      getListQuery: {
        userid: null,
        categoryid: null,
        searchtext: '',
      },
      dialogFormVisible: false,
      dialogFormVisible1: false,
      totalNumber: 0,
      isShow: true,

      list: [
        {
          registrationNumber: null,
          userMobile: null,
          userRegistTime: null,
          accountStatus: 0,
          userNick: null,
          enterpriseName: null,
          realname: null,
          businessLicense: null,
          accountMoney: null,
        },
      ],

      //   <li>用户名：{{list[index].userNick || ""}}</li>
      //   <li>公司名称：{{list[index].enterpriseName}}</li>
      //   <li>营业执照编码：{{list[index].registrationNumber}}</li>
      //   <li>联系人：{{list[index].realname}}</li>
      //   <li>联系方式：{{list[index].userMobile}}</li>
      //   <li>申请时间：{{list[index].userRegistTime | formatDateStr('yyyy/MM/dd')}}</li>
      //   <li style="color:red;">累计进货总额：{{list[index].accountMoney || 0}}</li>
      loading: true,
      showEditPage1: false,
      showEditPage2: false,
      showEditPage3: false,
      srcArr: [
        {
          url:
            'http://www.dnzhuti.com/uploads/allimg/160621/95-160621145918.jpg',
          title: '经营企业-营业执照',
          type: '通过',
          reason: '',
        },
      ],
      msg: '',
      licenseInfo: {
        accountStatus: 0,
        applyTime: null,
        businessLicense:
          'https://jintianhezong-1302324525.cos.ap-nanjing.myqcloud.com/HD1602319537000.jpg',
        enterpriseName: null,
        id: 12,
        realname: null,
        registrationNumber: null,
        userMobile: '18888888888',
        userNick: '金天国际',
        userRegistTime: 1599640366000,
        reasons: '',
        type: '审核中',
      },
      index: 0,
      reasons: '',
      reasonsSettlement: '', // 商家入驻驳回理由
      rejectData: {},
      userid: 0,
      busLicense: false,
      formSettled: {
        accountname: '银行开户名',
        accountnumber: '公司银行账号',
        address: '公司详细地址',
        affiliatedbanknumber: '支行联行号',
        agreementcontent: null,
        alipayname: '支付宝姓名',
        alipaynumber: '支付宝账号',
        bankaddress: '开户银行所在地',
        banklicenceurl:
          'http://49.235.101.52/jintianhezong/jintianhezongupload/jintianhezong/common/2020-12-11/KF1607676419126.jpg',
        businesslicenseindate: '2020-12-01   至   2021-01-31',
        businesslicensenumber: '营业执照号',
        businesslicenseurl:
          'http://49.235.101.52/jintianhezong/jintianhezongupload/jintianhezong/common/2020-12-11/LY1607676373344.jpg',
        categoryid: 446,
        certificationcontent: '',
        certificationstatus: 0,
        city: '合肥',
        companyname: '公司名称',
        companyphone: '公司电话',
        contactname: '联系人姓名',
        contactphone: '联系人电话',
        country: null,
        county: '创维',
        createtime: null,
        email: '电子邮箱',
        enterinfoid: 12,
        enterstep: 4,
        isdel: null,
        issign: null,
        province: '安徽',
        registeredcapital: 2222,
        rejectreason: null,
        remark: null,
        secondarycategoryid: 228,
        storename: '店铺名称',
        storesort: null,
        subbranchname: '开户银行支行名称',
        taxpayercertificate: null,
        taxpayercertificateurl:
          'http://49.235.101.52/jintianhezong/jintianhezongupload/jintianhezong/common/2020-12-11/NW1607676376842.jpg',
        topcategoryid: 203,
        totalstaff: 11111111,
        userid: 1,
        wechatname: '微信姓名',
        wechatnumber: '微信账号',
      }, // 商家入驻信息
      categoryTemplate: {
        id: 127,
        name: '酒饮模板',
        templateItemFormList: [
          {
            id: 203,
            templateid: 127,
            fieldtype: '数字',
            fieldname: '营业执照号',
            fieldvalue: '0000000000',
            ismust: 0,
          },
        ],
      },
    }
  },
  methods: {
    closeDialog() {
      this.showEditPage1 = false
      this.showEditPage2 = false
      this.showEditPage3 = false
    },
    /*点击页数*/
    handleCurrentChange(val) {
      this.query.currentPage = val
      //缓存当前页码数
      sessionStorage.setItem('currentPage', val)
      this.getCheckUser()
    },

    /*选择每页条数【10,20,30,40,50】*/
    handleSizeChange(val) {
      this.query.pageSize = val
      this.getCheckUser()
    },
    getCheckUser() {
      this.loading = true
      const formData = new FormData()
      for (const key in this.query) {
        formData.append(key, this.query[key])
      }

      getCheckUser(formData)
        .then((response) => {
          if (response.code != 0) {
            this.$message.error(response.message)
            this.loading = false
            return false
          }

          this.totalNumber = response.data.totalNumber
          this.list = response.data.list || []
          setTimeout(() => {
            this.loading = false
          }, 0.3 * 1000)
        })
        .catch(() => {
          this.loading = false
        })
    },
    rejectionApplication(type, data) {
      this.rejectData = data

      // let that = this;
      // for (const item of this.srcArr) {
      //     if (item.type == "驳回" && !item.reason) {
      //         //   this.msg = item.title + '被驳回的理由！'
      //         //   console.log('请填写"' + item.title + '"被驳回的理由！')
      //         this.$message({
      //             message: '请填写"' + item.title + '"被驳回的理由！',
      //             type: "warning"
      //         });
      //         break;
      //     }
      // }
      if (type == 1) {
        this.dialogFormVisible = true
        // this.showEditPage1 = false;
      } else if (type == 2) {
        this.dialogFormVisible = true

        // this.showEditPage2 = false;
      } else if (type == 3) {
        this.dialogFormVisible1 = true

      }
    },
    getsession() {
        if(sessionStorage.getItem('currentPage')>0){
            this.query.currentPage = Number(sessionStorage.getItem('currentPage'))
        }else{
            this.query.currentPage=1
        }


    },
    passApplication(type, data) {
      this.rejectData = data
      if (type == 1) {
        const formData = new FormData()
        formData.append('id', this.list[this.index].id)
        formData.append('reason', this.reason)
        formData.append('status', 1)
        updateCheckEntityStatus(formData)
          .then((response) => {
            if (response.code != 0) {
              this.$message.error(response.message)
              return false
            }

            this.$message.success('通过审核！')
            this.dialogFormVisible = false
            this.showEditPage1 = false

            this.onRest()
            setTimeout(() => {
              this.loading = false
            }, 0.3 * 1000)
          })
          .catch(() => {
            this.loading = false
          })

        this.showEditPage1 = false
      } else if (type == 2) {
        this.loading = true
        let data = {
          categoryid: this.rejectData.categoryid,
          certificationcontent: JSON.stringify(
            this.rejectData.certificationcontent
          ),
          certificationid: this.rejectData.certificationid,
          certificationstatus: 1,
          rejectreason: this.reasons,
          id: this.userid,
        }
        merchantsCertificationAudit(data)
          .then((response) => {
            if (response.code != 0) {
              this.$message.error(response.message)
              return false
            }
            this.$message.success('审批成功！')
            this.showEditPage2 = false
            this.onRest()
            setTimeout(() => {
              this.loading = false
            }, 0.3 * 1000)
          })
          .catch(() => {
            this.loading = false
          })
      } else if (type == 3) {
        // 商家入驻审核 通过
        this.loading = true
        this.formSettled.certificationstatus = 1
        audit(this.formSettled)
          .then((response) => {
            if (response.code != 0) {
              this.$message.error(response.message)
              return false
            }

            this.$message.success('通过审核！')
            this.dialogFormVisible1 = false
            this.showEditPage3 = false
            // debugger
            // console.log(this.query.currentPage)
            //做分页记忆功能
            if (this.query.currentPage !== 0) {
              this.getCheckUser()
            } else {
              this.onRest()
            }

            setTimeout(() => {
              this.loading = false
            }, 0.3 * 1000)
          })
          .catch(() => {
            this.loading = false
          })
      }
    },
    // 驳回
    reject() {
      if (this.busLicense) {
        // console.log(this.list[this.index])
        const formData = new FormData()
        formData.append('id', this.list[this.index].id)
        formData.append('reason', this.reason)
        formData.append('status', 2)
        updateCheckEntityStatus(formData)
          .then((response) => {
            if (response.code != 0) {
              this.$message.error(response.message)
              return false
            }
            this.$message.success('已驳回！')
            this.dialogFormVisible = false
            this.showEditPage1 = false
            this.onRest()
            setTimeout(() => {
              this.loading = false
            }, 0.3 * 1000)
          })
          .catch(() => {
            this.loading = false
          })
        return false
      }
      // categoryid	integer($int64) 分类认证ID
      // certificationcontent	string certificationcontent 资质内容
      // certificationid	integer($int64) 商家类目资质审核ID
      // certificationstatus	integer($int32) 资质审核状态：0.审核中 1.审核通过 2.驳回
      // rejectreason	string 驳回理由
      // userid	integer($int64) 商家商城ID
      let data = {
        categoryid: this.rejectData.categoryid,
        certificationcontent: JSON.stringify(
          this.rejectData.certificationcontent
        ),
        certificationid: this.rejectData.certificationid,
        certificationstatus: 2,
        rejectreason: this.reasons,
        id: this.userid,
      }
      // categoryid;
      merchantsCertificationAudit(data)
        .then((response) => {
          if (response.code != 0) {
            this.$message.error(response.message)
            return false
          }
          this.$message.success('已驳回！')
          this.dialogFormVisible = false
          this.showEditPage2 = false
          this.onRest()
          setTimeout(() => {
            this.loading = false
          }, 0.3 * 1000)
        })
        .catch(() => {
          this.loading = false
        })
    },
    // 商家入驻驳回
    rejectSettlement() {
      if (!this.reasonsSettlement) {
        this.$message.warning('请填写驳回原因！！！')
        return false
      }
      // 商家入驻审核 通过
      this.loading = true
      this.formSettled.certificationstatus = 2
      this.formSettled.rejectreason = this.reasonsSettlement
      audit(this.formSettled)
        .then((response) => {
          if (response.code != 0) {
            this.$message.error(response.message)
            return false
          }
          this.$message.success('审核已被驳回！')
          this.dialogFormVisible1 = false
          this.showEditPage3 = false
          this.onRest()
          setTimeout(() => {
            this.loading = false
          }, 0.3 * 1000)
        })
        .catch(() => {
          this.loading = false
        })
    },
    // 商品类目审批
    approvalCategory() {},
    onRest() {
      this.query = {
        currentPage: 1,
        pageSize: 10,
        userPhone:"",
        UserNick :"",
        certificationstatus:'',
        RegistrationNumber:'',
        enterpriseName:""
      }
      this.getCheckUser()
    },
    onSubmit() {
      this.query.currentPage = 1
      this.getCheckUser()
    },
    showEdit(type, index, row) {
      this.userid = row.userid
      this.index = index
      this.licenseInfo = index
      if (type == 1) {
        this.busLicense = true
        this.showEditPage1 = true
      } else if (type == 2) {
        this.busLicense = false
        this.showEditPage2 = true
      } else if (type == 3) {
        getDetailInfo({ userId: row.userId })
          .then(async (response) => {
            if (response.code != 0) {
              this.$message.error(response.message)
              return false
            }

            this.formSettled = response.data || {}
            console.log(this.formSettled)
            this.categoryTemplate = JSON.parse(
              response.data.certificationcontent
            )
            this.showEditPage3 = true
          })
          .catch(() => {})
      }
    },
    goCommodityManagement(data) {
      this.getListQuery.userid = data.userId
      this.getListQuery.categoryid = data.categoryid
      this.getListQuery.searchtext = this.query.userPhone
      this.showEditPage2 = true
      this.isShow = false
    },
    goBack() {
      this.isShow = true
    },
  },
  filters: {
    statusFilter(status) {
      let statusFilter = ''
      switch (status) {
        case 2:
          statusFilter = '已驳回'
          break
        case 1:
          statusFilter = '已通过'
          break
        case 0:
          statusFilter = '审核中'
          break
        default:
          statusFilter = '审核中'
          break
      }
      return statusFilter
    },
    getTemplateTyep(type) {
      let templateName = '供应型'
      switch (type) {
        case 1:
          templateName = '供应型'
          break
        case 2:
          templateName = '营销型'
          break
        case 3:
          templateName = '资源型'
          break
        default:
          templateName = '供应型'
          break
      }
      return templateName
    },
  },
  created() {
    this.getCheckUser()
  },
  mounted() {
    this.getsession()
  },
}
</script>

<style scoped lang="scss">
.qualificationCertificate .el-col div .el-select {
  min-height: auto !important;
}
.topList {
  background-color: #f2f2f2;
  padding: 20px;
  li {
    line-height: 40px;
  }
}
.certificateTit {
  font-size: 20px;
  font-weight: 400;
  margin: 20px 0;
  color: #000;
  position: relative;
  .getList {
    position: absolute;
    right: 0;
    font-size: 16px;
    color: #3a5ca0;
    cursor: pointer;
  }
}

.getList {
  color: #3a5ca0;
  cursor: pointer;
}
.imgBox {
  overflow: hidden;
  max-width: 200px;
  height: 150px;
  border-radius: 5px;
  margin: 10px 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  align-content: center;
  position: relative;
  box-shadow: 0 0 5px 1px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  p {
    position: absolute;
    bottom: 0;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    text-shadow: -1px 1px 1px rgba(255, 255, 255, 0.5);
    color: #fff;
    height: 30px;
    line-height: 30px;

    box-sizing: border-box;
    text-align: center;
  }
  img {
    height: auto;
    max-width: 200px;
    border-radius: 5px;
    margin: auto;
  }
}
.qualificationCertificate {
  padding: 20px 0;
  border-top: 2px solid #8c8c8c;
  // border-bottom: 2px solid #8c8c8c;
  h4 {
    font-size: 18px;
    font-weight: 400;
    color: #000;
    margin: 20px 0;
  }
  .el-row {
    // flex-flow: wrap row;
  }
  .el-col {
    .el-popover {
    }
    .minHeigth {
      //   min-height: 100px;
    }
  }
  img {
    display: block;
    margin: 10px auto;
  }
  p {
    text-align: center;
  }
  .bottomList {
    padding: 20px;
    li {
      line-height: 40px;
    }
  }
  .btnBox {
    text-align: right;
  }
}
.thrTitle {
  width: 200px;
  text-align: right;
  padding-right: 20px;
  font-size: 16px;
  font-weight: 600;
  margin: 20px 0;
}
/deep/ .el-dialog__body {
  padding: 20px;
}
.settledInfo {
  /deep/ .el-form-item {
    margin-bottom: 0;
  }
}
</style>
